<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<link href="themes/css/ui.common.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet" type="text/css" />
		<link href="style/jquery_ui/jquery-ui-1.8.custom.css" rel="stylesheet"
			type="text/css" />
		<link id="skin_css" rel="stylesheet" type="text/css"
			href="themes/css/ui.c.blue.css"></link>
		<link rel="stylesheet" href="themes/default/pagination.css"
			type="text/css"></link>
		<link rel="stylesheet" href="themes/css/ui.validation.css" type="text/css"></link>
		<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src="Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src="Scripts/ui.tips.js" type="text/javascript"></script>
		<script src="Scripts/ui.default.js " type="text/javascript"
			charset="UTF-8"></script>
		<script src="Scripts/ui.admincp.js" type="text/javascript"
			charset="UTF-8"></script>
		<script type="text/javascript" src="Scripts/jquery.json-2.2.min.js"></script>
		<STYLE type="text/css">
		.editorArea {
			display: none;
		}
		</STYLE>
		<script type="text/javascript" src="Scripts/ui.dialogFormHelper.js"></script>
		<script type="text/javascript" src="Scripts/ui.validation.js"></script>
		<script type="text/javascript">
		$(function () {
			setValidate();
		});
		
		function setValidate(){  
	   		$("#form").validatingForm({
	      	  submitButtonId:"#btnSubmit",
	     	  clearErrorsOnFocus:true,
	      	  validateOnBlur:true,
	      	  summaryTo:"#errorSummary"
	       });
	    }
		
		function queryStudent(){
			$("#txt_states").append().html('');
			var stuNo = $("#txt_stuNo").val();
			$.post("studentInfo!queryByStuNo.action", {"stuNo":stuNo},
			function (data) {
				var jsonData = $.evalJSON(data);
				
				var avatarId = jsonData.avatarInfo.avatarId;
				var gender = jsonData.stuDetail.gender;
				var grade= jsonData.stuDetail.grade;
				var classNo = jsonData.stuDetail.classNo;
				$("#txt_stuId").val(jsonData.id);
				$("#txt_avatarId").val(jsonData.avatarInfo.avatarId);
				$("#txt_stuNo").val(jsonData.stuNo);
				$("#txt_stuName").text(jsonData.stuName);
				$("#txt_idCard").text(jsonData.stuDetail.idCard);
				$("#dl_gender").text(jsonData.stuDetail.gender);
				if(jsonData.mailInfo != null)
				$("#txt_mail").text(jsonData.mailInfo.mail);
				if(jsonData.stuDetail!=null){
					$("#txt_detailId").val(jsonData.stuDetail.id);
					$("#txt_hometown").text(jsonData.stuDetail.hometown);
					$("#dl_politician").text(jsonData.stuDetail.politician);
					$("#txt_telphone").val(jsonData.stuDetail.telphone);
					$("#txt_grade").text(jsonData.stuDetail.grade);
					$("#txt_classNo").val(jsonData.stuDetail.classNo);
					$("#txt_cardId").text(jsonData.stuDetail.cardId);
					if(jsonData.stuDetail.majorInfo != null)
					$("#txt_majorName").text(jsonData.stuDetail.majorInfo.majorName);
					if(jsonData.stuDetail.familyInfo != null){
						$("#txt_familyId").val(jsonData.stuDetail.familyInfo.id);
						$("#txt_fatherName").val(jsonData.stuDetail.familyInfo.fatherName);
						$("#txt_fatherTel").val(jsonData.stuDetail.familyInfo.fatherTel);
						$("#txt_motherName").val(jsonData.stuDetail.familyInfo.motherName);
						$("#txt_motherTel").val(jsonData.stuDetail.familyInfo.motherTel);
						$("#txt_address").val(jsonData.stuDetail.familyInfo.address);
					}
					if(jsonData.stuDetail.scoreInfo != null){
						$("#txt_examNo").text(jsonData.stuDetail.scoreInfo.examNo);
						$("#txt_chinese").text(jsonData.stuDetail.scoreInfo.chinese);
						$("#txt_math").text(jsonData.stuDetail.scoreInfo.math);
						$("#txt_english").text(jsonData.stuDetail.scoreInfo.english);
						$("#txt_comprehensive").text(jsonData.stuDetail.scoreInfo.comprehensive);
						$("#txt_sumScore").text(jsonData.stuDetail.scoreInfo.sumScore);
					}
					
					if(jsonData.stuDetail.bedInfo != null){
						$("#txt_bedInfo").text(jsonData.stuDetail.bedInfo.bedInfoDetail);
						$("#dl_bedInfo").attr("style", "visibility:hidden");
					}else{
						$("#txt_bedInfo").text("");
						$("#dl_bedInfo").attr("style", "width: 180px; height: 26px");
					}
				}
				var states = jsonData.states;
				if(states < 3 && states >= 0 ){
					$("#txt_states").append("<font color='blue'>未注册</font>");
				}else if(states == 3){
					$("#txt_states").append("<font color='green'>财务已审核</font>");
				}else{
					$("#txt_states").append("<font color='red'>已注册</font>");
				}
				document.getElementById("img_photo").src = "getPhoto.action?avatarId="+avatarId+"&gender="+gender;
				$.post("studentInfo!queryBedInfo.action", {"gender":gender,"classNo":classNo,"grade":grade}, function(data){
						$("#dl_bedInfo").attr("disabled",false);
			            $("#dl_bedInfo").html("").append(data);
				});
				
			}); 
		}
		</script>
	</head>
	<body>
		<div class="PageChild_Title">
			<img src=" themes/images/default/icons/archives.png"
				class="PageChild_Tbtnpic" />
			<span class="PageChild_separate"></span>
			<span class="PageChild_TbtnText">
				<h2>注册学生信息	</h2>
			</span>
			<span class="PageChild_separate"></span>
			<div id="marker" class="red-tips">
			</div>
			<div class="clear">
			</div>
		</div>
		<s:form action="studentInfo!registStudent.action" method="post" enctype ="multipart/form-data">
		<table  id="form" style="border: 1px solid gray; padding: 1px;" border="0"
			cellpadding="0" cellspacing="0" align="center">
			<tr>
				<td colspan="8" align="center">
					<s:hidden id="txt_stuId" name="stuId" theme="simple"/>
					<s:hidden id="txt_detailId" name="detailId" theme="simple"/>
					<s:hidden id="txt_familyId" name="familyId" theme="simple"/>
					<s:hidden id="txt_avatarId" name="avatarId" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<b>基本信息</b>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;学号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_stuNo" name="stuNo" fieldName="学号" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
					<input type="button" class="o-btn" value="查询" onclick="queryStudent();"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;姓名:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_stuName"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;银行卡号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_cardId"></label>
				</td>
				<td style="width: 300px" valign="middle" align="center" class="style1" rowspan="5" colspan="2">
					<img id="img_photo" alt="一寸照片" src="getPhoto.action"><br />
					&nbsp;照片：<s:file name ="stuPhoto" cssClass="control-width-100 input-control" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;性别:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="dl_gender"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;身份证号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_idCard"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;邮箱:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_mail"></label>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;家乡:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_hometown"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;政治面貌:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="dl_politician"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;手机号码:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_telphone" name="telphone" fieldName="手机号码" cssClass="control-width-100 required-field telphone-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;专业:
				</td>
				<td style="width: 130px" valign="middle" class="style1">
					<label id="txt_majorName"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;年级:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_grade"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;班级:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_classNo" name="classNo" fieldName="班级" cssClass="control-width-100 required-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;状态:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<div id="txt_states"></div>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;宿舍床位:
				</td>
				<td style="width: 440px" valign="middle" class="style1" colspan="4">
					<label id="txt_bedInfo"></label><s:select list="{}" id="dl_bedInfo" name="bedId" theme="simple" emptyValueMsg="请选择床位。" emptyValueForValidate="-1" disabled="true" cssClass="control-width-40 clearable" cssStyle="width: 180px; height: 26px"></s:select>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<br /><b>家庭信息</b>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;父亲姓名:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_fatherName" name="fatherName" fieldName="父亲姓名" cssClass="control-width-100 required-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;联系电话:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_fatherTel" name="fatherTel" fieldName="父亲联系电话" cssClass="control-width-100 telphone-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;母亲姓名:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_motherName" name="motherName" fieldName="母亲姓名" cssClass="control-width-100 required-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;联系电话:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_motherTel" name="motherTel" fieldName="母亲联系电话" cssClass="control-width-100 telphone-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;家庭地址:
				</td>
				<td style="width: 110px" valign="middle" class="style1" colspan="7">
					<s:textfield id="txt_address" name="address" fieldName="家庭地址" cssClass="control-width-100 required-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<br /><b>入学成绩</b>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;考号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_examNo"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;总成绩:
				</td>
				<td style="width: 110px" valign="middle" class="style1" colspan="4">
					<label id="txt_sumScore"></label>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;语文:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_chinese"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;数学:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_math"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;外语:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_english"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;综合:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_comprehensive"></label>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<input id="btnSubmit" type="submit" class="o-btn" value="注册"/>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<div id="errorSummary"></div>
				</td>
			</tr>
		</table>
		</s:form>
		<div id="errorSummary"></div>
	</body>
</html>